; short int* sumaYResta(short int* v, short int* w, unsigned short n);

extern malloc

global sumaYResta

%define ptr_v [ebp + 8]
%define ptr_w [ebp + 12]
%define n [ebp + 16]

section .text

sumaYResta:
	push ebp
	mov ebp, esp
	push esi
	push edi
	push ebx
	
	mov edi, ptr_v
	mov esi, ptr_w 
	xor ecx, ecx
	mov cx, n
	
	mov edx, ecx
	shl edx, 1
	push edx
	call malloc
	add esp, 4
	cmp eax, 0
	je fin
	
	shr ecx, 2
	movq mm1, 0xFF00FF00h
	
ciclo:
	movq mm0, [esi + ecx * 8 - 8]
	paddw mm0, [edi + ecx * 8 - 8]
	pand mm0, mm1
	movq [eax + ecx * 8 - 8], mm0
	loop ciclo
	
fin:
	pop ebx
	pop edi
	pop esi
	pop ebp
	ret
